***
* BINDER DATA/GRIDLOCK REPLICATION
***
* This is the final replication file for the section on Gridlock.
* It begins with data that Prof. Binder emailed Prof. Milner.
* Prof. Binder also sent along a mini-codebook called "Codebook for milner.doc" that we have in the Binder folder.


use gridlock.dta, clear

* For classifying issues by Foreign Vs Domestic policy, Binder uses the Policy Agendas dataset.
* "foreign3" is a dummy variable that equals 1 if the issue fell under Policy Agendas headings 16, 18, or 19.
* Note that we're also reversing the coding of gridlock: "final2" is Binder's variable and equals 1 if the issue was enacted.
* "final1" is our construct which simply equals 1 if the issue was not enacted.

* This generates the percentages of issues that were gridlocked by congressional session, and broken down by foreign and domestic issues.
bysort congress: egen glock_all_xx=mean(final2)
gen glock_all=1-glock_all_xx
bysort congress: egen glock_fp_xx1=mean(final2) if foreign3==1
	bysort congress: egen glock_fp_xx2=min(glock_fp_xx)
gen glock_fp=1-glock_fp_xx2
bysort congress: egen glock_dp_xx1=mean(final2) if foreign3!=1
	bysort congress: egen glock_dp_xx2=min(glock_dp_xx)
gen glock_dp=1-glock_dp_xx2

drop *_xx*

* This is where we reverse the coding from Binder's coding of gridlock.  final2 is used in the regressions later.
gen final1=0
replace final1=1 if final2==0



***
* Submission Draft Figure 1
***
* This produces figure 1, which plots gridlock over time.
preserve
duplicates drop congress, force
local low 80
local high 106
local lines "xline(91 102)"
twoway connect glock_dp glock_fp congress if congress>=`low' & congress<=`high', `lines' title("Figure 1. Legislative Gridlock Over Time, 1947 to 2001", size(medium)) yaxis(1) lp(dash solid) lw(medium medium) legend(order(1 "domestic policy issues" 2 "foreign policy issues")) ytitle("gridlock") xtitle("Congress") msize(vsmall vsmall) ylabel(0(.2)1, format(%02.1f))
* This is a note we ended up not using, because it's in the text:
* note("NOTE: For each Congress, the vertical axis, gridlock, measures the percentage of important" "issues for which there was no legislative action during that particular congress.  The vertical lines" "mark the 91st and 101st Congress, which were around the time of end of the Vietnam and Cold" "Wars, respectively.")
*graph save "glock_dp_fp.gph", replace
restore



***
* GRIDLOCK REGRESSIONS
***
* This section runs the regressions mentioned in the Gridlock section.
* It loops through various cutoffs, ranging from the 89th to 93rd Congresses
* Draft footnote 9 uses the 91st Congress as the "Post-Vietnam" cutoff
forvalues i=89(1)93 {
	probit final1 congress if congress>=`i', cluster(congress)
	est store All_`i'
	probit final1 congress if foreign3==1 & congress>=`i', cluster(congress)
	est store FP_`i'
	*esta _all using "Binder_Post1970_`i'.doc" , drop(_cons) title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace
}
*esta All_Iss FP_Iss All_91 FP_91 using "Binder_Post1970.doc" , drop(_cons) title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace




***
* COLD WAR BREAKS, DIFFERENCE IN MEANS
***
* This section produces the regressions mentioned regarding gridlock before and after the Cold War.
* This section loops over various starting congresses, for the end of Vietnam, and over various congresses around the end of the Cold War.
* As described in the footnotes and data appendix, the ending and starting points don't matter for the result.  They're a robustness check.

* This is for all issues (foreign and domestic)
forvalues i=99(1)103	{
	gen cwar_`i'=0
	replace cwar_`i'=1 if congress>=`i'
	est clear
		forvalues j=88(1)93	{
			di "`j' ... `i'"
			probit final1 cwar_`i' if congress>=`j', cluster(congress)
			est store cwar_`i'_`j'
}
	*esta _all using "Binder_CWar_`i'.doc",  drop(_cons) title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace
}

* This is for foreign policy issues only
forvalues i=99(1)103	{
	est clear
		forvalues j=88(1)93	{
			di "`j' ... `i'"
			probit final1 cwar_`i' if congress>=`j' & foreign3==1, cluster(congress)
			est store cwar_`i'_`j'
}
	*esta _all using "Binder_CWar_`i'_FP.doc",  drop(_cons) title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace
}




***
* PREDICTED PROBABILITY OF GRIDLOCK PLOT
***
* This section produces the plot of the predicted probability of gridlock over time
* Note: this figure was actually cut during editing for length reasons.
* For our reference, it was Figure 2 in the original submission draft.

estimates clear
probit final1 congress if congress>=91, cluster(congress)
est store All_For
predict AllIssues , pr
probit final1 congress if foreign3==1 & congress>=91, cluster(congress)
est store FP_For
predict FPIssues  , pr
*esta _all  using "Binder_SubsEff_91.doc" , `order' title("Title") starlevels(+ 0.10 * 0.05 ** 0.01)  se  nom nonum nodep nogaps  b(a3)  label brackets  compress replace

preserve
duplicates drop congress, force
local low 91
local high 106
local lines "xline(102)"
twoway connect AllIssues FPIssues congress if congress>=`low' & congress<=`high', title("Predicted Probability of Gridlock Over Time, 91st-106th Congress", size(medium)) lp(dash solid) lw(medium medium) msymbol(i i) xlab(91(1)106) ylab(0(.2)1) legend(order(1 "All Issues" 2 "Foreign Policy Issues")) ytitle(Predicted Probability) xtitle(Congress) msize(medlarge large) `lines'
*graph save PredictProb_Post91st, replace
restore
